<?php

class InputValidationHandler {
	
	const E_MAIL_REGEXP = '/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/';
	const USER_REGEXP = '/^(?=.{2,20}$)[a-zA-Z][a-zA-Z0-9åäöÅÄÖ]*(?: [a-zA-Z0-9åäöÅÄÖ]+)*$/';
	//const PASS_REGEXP = '/^(?=.{2,15}$)[a-zA-Z][a-zA-Z0-9]*(?: [a-zA-Z0-9]+)*$/';
	//const QUESTION_REGEXP = '/^(?=.{1}$)[2]*$/';



	 //Email

	public static function isValidEmail($email){
		trim($email);
		return preg_match(self::E_MAIL_REGEXP, $email);
	}
	
	//HumanQuestion
	//public static function isValidQuestion($human){
		//return preg_match(self::QUESTION_REGEXP, $human);
	//}
	

	//användarnamn och lösen

	/*public static function isValidPass($pass){
		//$pass = trim($pass);
		return preg_match(self::PASS_REGEXP, $pass);
	}
	 * 
	 */
	
	public static function isValidUser($user){
		//$user = trim($user);
		return preg_match(self::USER_REGEXP, $user);
	}
	
	public static function getValidMessage($message){
		$okTags = '<p>';
		return strip_tags($message, $okTags);
	}	

}
